package com.hermes.test;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.hermes.biz.common.model.result.UserResultDO;
import com.hermes.biz.common.model.user.UserDO;
import com.hermes.biz.common.model.user.UserPublicDO;
import com.hermes.biz.manager.user.UserOperateManager;
import com.hermes.common.action.AsynBaseAction;
import com.hermes.common.util.LoginHelperUtil;
import com.hermes.common.util.ParameterParserUtil;

public class LogoSet extends AsynBaseAction{

	private static final long serialVersionUID = 1L;

	public UserOperateManager userOperateManager;
		
	public UserPublicDO userPublicDO;

	public UserDO userDO;
	public String userid="";
	public String username;

	public boolean isLogin = false;
	
	@Override
	public String execute() throws Exception {
		
		//判断是否登录
		HttpServletRequest request = ServletActionContext.getRequest();
		LoginHelperUtil loginHelper = new LoginHelperUtil(request);
		if(loginHelper.hasLogined()){
			setLogin(true);
			userPublicDO = loginHelper.getUserPublicDO();
			username=loginHelper.getCurrentUserName();
		}
		
        userid=ParameterParserUtil.getParameter("userid");
        UserResultDO resultDO = userOperateManager.getSingleUserByUserId(Long.valueOf(userid));
		userDO = resultDO.getModule();	
		return SUCCESS;
	}

	public UserPublicDO getUserPublicDO() {
		return userPublicDO;
	}

	public void setUserPublicDO(UserPublicDO userPublicDO) {
		this.userPublicDO = userPublicDO;
	}

	public boolean isLogin() {
		return isLogin;
	}

	public void setLogin(boolean isLogin) {
		this.isLogin = isLogin;
	}
	
	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}
	//getters and setters
	public UserOperateManager getUserOperateManager() {
		return userOperateManager;
	}
	public void setUserOperateManager(UserOperateManager userOperateManager) {
		this.userOperateManager = userOperateManager;
	}
}
